package com.example.canalclientsync.script;

import com.example.canalclientsync.canal.handler.DirHandler;
import com.example.canalclientsync.canal.mapper.db1.DirMapper;
import com.example.canalclientsync.canal.po.Dir;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * 文件夹数据同步
 *
 * @author chen.cr
 * @since 2023/10/17
 */
@Component
@Slf4j
public class DirSync extends BasicSync<Dir, Long>{

    @Resource
    private DirMapper dirMapper;
    @Resource
    private DirHandler dirHandler;

    @Override
    long countTotal() {
        return dirMapper.findAllDataCount();
    }

    @Override
    List<Dir> findPageData(long offset, int limit) {
        return dirMapper.findPageData(offset, limit);
    }

    @Override
    void sync0(Dir dir) {
        dirHandler.insert(dir);
    }

    @Override
    Long getKey(Dir dir) {
        return dir.getId();
    }

}
